﻿use persons
go
------------------3----------------------------------------------------------------
/*Find person by contact*/
DECLARE  @CONTACT INT
SET @CONTACT=5
SELECT 
[Person].[FirstName], 
[Person].[LastName]
FROM [dbo].[Contact], [dbo].[Person] 
WHERE [Person].[ID]=[Contact].[fk_personId] AND [Contact].[ID]=@CONTACT

SELECT 
[Person].[FirstName], 
[Person].[LastName]
FROM [dbo].[Contact] INNER JOIN [dbo].[Person] 
ON [Person].[ID]=[Contact].[fk_personId] WHERE [Contact].[ID]=@CONTACT

SELECT 
[Person].[FirstName], 
[Person].[LastName]
FROM [dbo].[Person] WHERE [Person].[ID] IN(SELECT  
[Contact].[fk_personId] 
FROM [dbo].[Contact] WHERE[Contact].[ID]=@CONTACT)
